<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/jsp/common/common.jsp"%>
<%
	String domainId = request.getAttribute("domainId") == null?"":request.getAttribute("domainId").toString();
	String parentId = request.getAttribute("parentId") == null?"":request.getAttribute("parentId").toString();
%>
</head>
<body>

	<div class="documentContent" id="documentContent">

		<!-- form-box -->
		<div class="form-box">
			<h2 class="form-title">机构信息</h2>
			<div class="form-content">
				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="form-table">
					<tr>
						<td class="form-table-tdleft" width="25%">机构名称：</td>
						<td width="75%"><input class="table-input" type="text" name="name" id="name" value="" /></td>
					</tr>
					<tr>	
						<td class="form-table-tdleft">机构编号：</td>
						<td><input class="table-input" type="text" name="serialNumber" id="serialNumber" value="" /></td>
					</tr>
					<tr>
						<td class="form-table-tdleft">机构级别：</td>
						<td><select class="table-input" id="levelId"></select></td>
					</tr>
					<tr>	
						<td class="form-table-tdleft">状态：</td>
						<td>
							<select class="table-input" id="state">
					  			<option value="A">启用</option>
					  			<option value="F">禁用</option>
				      	   	</select>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<!-- form-box -->
		
		<input type="hidden" name="domainId" id="domainId" value="<%=domainId %>" />
		<input type="hidden" name="parentId" id="parentId" value="<%=parentId %>" />

	</div>

<script type="text/javascript">

var domainId = '<%=domainId %>';
var parentId = '<%=parentId %>';


$(document).ready(function(){
	
	getPageData();

});

function getPageData(){
	getOrgLevel();
}

function onConfrim(layerObject,zTreeGobalObjcet){
	
	var url = '<%=basePath%>/biz/ou/org/saveOrganization.do';
	var jsonData = new Object();
	$('body').find(':input').each(function(index,element){
		var key = $(element).attr('id');
		var value = $(element).val();
		if(key){
			jsonData[key] = value;
		}
	});
	
	var jsonDataStr = JSON.stringify(jsonData);
	$.ajax({
		url : url,
		type : 'post',
		dataType : 'json',
		data:{jsonData:jsonDataStr},
		success : function(data, textStatus, jqXHR) {
			showAlert('添加成功',function(){
				layerObject.close();
				zTreeGobalObjcet.reAsyncChildNodes(null, "refresh");
			});
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
		}
	});
	
	return true;
}


function getOrgLevel(){
	var url = '<%=basePath%>/biz/ou/org/getOrganizationLevelData.do?domainId=<%=domainId %>';
	
	$.ajax({  
        url:url,  
        type:'post',  
        dataType:'json',  
        success:function(data,textStatus,jqXHR){  
        	
        	$('#levelId').append('<option value="">请选择</option>');
        	
        	$(data.data).each(function(index,entry){
        		var optionObj = $('<option></option>').append(entry.orgLevelName).attr('value',entry.id);
        		$('#levelId').append(optionObj);
        	});
        	
        },  
        error:function(XMLHttpRequest,textStatus,errorThrown){  
        }                     
    });
	
}

</script>
</body>
</html>